package com.heaboy.collection;

import java.util.Queue;
import java.util.Stack;

public class StackExample{
    public static void main(String[] args) {
            MyQueue myQueue=new MyQueue();
            myQueue.push1(1);
            myQueue.push1(2);
            int sum=myQueue.push1(3);
            for(int i=0;i<sum;i++){
                System.out.print(myQueue.pop1());
            }
    }
}
class MyQueue {
    Stack<Integer> stack=new Stack();
    Stack<Integer> stack1=new Stack<>();
    //记录入队的次数
    int sum=0;
    //入队
    public int push1(int a){
        stack.push(a);
        sum++;
        return sum;
    }
    //出队
    public int pop1(){
        while(!stack.isEmpty()){
            stack1.push(stack.pop());
        }
        return stack1.pop();
    }
}
